#pragma once
#include<iostream>
#include<vector>
#include<stack>
#define infinity -1
using namespace std;
namespace GIS20144
{
	void function(vector<vector<int>>& map, int source)
	{
		vector<int> index1(map.size(), 0);
		index1[source] = 1;
		cout << source << "->";
		DFS(map, index1, source);

		vector<int> index2(map.size(), 0);
		index2[source] = 1;
		stack<int> stak;
		stak.push(source);
		int count = 1;
	}
	void DFS(vector<vector<int>>& map, vector<int>& index, int source)
	{
		for (int j = 0; j < map[0].size(); j++)
		{
			if (map[source][j] != infinity && index[j] == 0)
			{
				index[j] = 1;
				cout << index[j] << "->";
				DFS(map, index, j);
			}
		}
	}

	void BFS(vector<vector<int>>& map, vector<int>& index, stack<int>& stak, int& count)
	{
		while (stak.empty())
		{
			int temp = 0;
			while (count--)
			{
				int i = stak.top();
				stak.pop();
				for (int j = 0; j < map.size(); j++)
				{
					if (map[i][j] != infinity && index[j] == 0)
					{
						index[j] = 1;
						stak.push(j);
						temp++;
					}
				}
			}
			count = temp;
		}
	}
}